package com.mybatisplus.sunpineshop.works.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mybatisplus.sunpineshop.works.entity.SWorks;
import com.mybatisplus.sunpineshop.works.mapper.SWorksMapper;
import com.mybatisplus.sunpineshop.works.service.SWorksService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2021-02-25
 */
@Service
@Primary
public class SWorksServiceImpl extends ServiceImpl<SWorksMapper, SWorks> implements SWorksService {
    @Autowired
    SWorksMapper sWorksMapper;

    /**
     * 根据作品的ID查询所有作品（不含作者）
     * @return
     */
    @Override
    public List<SWorks> findsWorksList(QueryWrapper<SWorks> queryWrapper){
//        QueryWrapper<SWorks> queryWrapper = new QueryWrapper<SWorks>();
//        queryWrapper.orderByDesc("update_time");
//        queryWrapper.orderByDesc("likenum"+"browsenum");
        List<SWorks> t = (List<SWorks>) sWorksMapper.selectList(queryWrapper);
        return t;
    }

    /**
     * 根据作品的ID查询所有作品（含作者）
     * @param queryWrapper
     * @return
     */
    @Override
    public List<Map> findAll(Wrapper<SWorks> queryWrapper) {
        List<Map> sWorksList = sWorksMapper.findAll(queryWrapper);
        return sWorksList;
    }

    /**
     * 轮播图显示的查询
     * @return
     */
    @Override
    public List<Map> randomSelect() {
        List<Map> sWorksList = sWorksMapper.randomSelect();
        return sWorksList;
    }

}
